function* foo() {
  console.log("函数开始执行");
  const value1 = 100;
  try {
    yield value1;
  } catch (err) {
    console.log("捕获到异常：", err);
  }

  const value2 = 200;
  yield value2;

  console.log("函数执行结束");
}

const generator = foo();

const res = generator.next();
if (res.value !== 200) {
  console.log(generator.throw("error message"));
}
